shorthandproperty: Use alloc a for data array
authorTimm Bäder <mail@baedert.org>
Sat, 18 Apr 2020 08:54:44 +0000 (10:54 +0200)
committerTimm Bäder <mail@baedert.org>
Tue, 5 May 2020 06:20:09 +0000 (08:20 +0200)
gtk/gtkcssshorthandproperty.c

index c33bbe449f340beab97934b505376c99cc6efc3b..50ef48e9286a916ce46703f3038149f365539247 100644 (file)
@@ -71,7 +71,8 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
   GtkCssValue *result;
   guint i;
 
-  data = g_new0 (GtkCssValue *, shorthand->subproperties->len);
+  data = g_newa (GtkCssValue *, shorthand->subproperties->len);
+  memset (data, 0, sizeof (GtkCssValue *) * shorthand->subproperties->len);
 
   if (gtk_css_parser_try_ident (parser, "initial"))
     {
@@ -114,7 +115,6 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
           if (data[i] != NULL)
             _gtk_css_value_unref (data[i]);
         }
-      g_free (data);
       return NULL;
     }
 
@@ -128,8 +128,7 @@ gtk_css_shorthand_property_parse_value (GtkStyleProperty *property,
     }
 
   result = _gtk_css_array_value_new_from_array (data, shorthand->subproperties->len);
-  g_free (data);
-  
+
   return result;
 }